using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using NUnit.Framework;
using OpenTK.Math;

namespace Dogfight2008.Common.Tests
{
  [TestFixture]
  public class CubeCreatorFixture
  {
    [Test]
    public void Generate()
    {
      ColoredTriangleSoup cube = CubeCreator.Generate(Color.Yellow, 10);
    }

    [Test]
    public void Count()
    {
      ColoredTriangleSoup cube = CubeCreator.Generate(Color.Yellow, 10);
      Assert.AreEqual(6 * 2, cube.TriangleCount);
    }

    [Test]
    public void AllSameColor()
    {
      ColoredTriangleSoup cube = CubeCreator.Generate(Color.Yellow, 10);
      foreach (ColoredTriangle tri in cube)
        Assert.AreEqual(Color.Yellow, tri.Color);
    }

    [Test]
    public void AllCoordinatesAreZeroOrSide()
    {
      float side = 10;
      ColoredTriangleSoup cube = CubeCreator.Generate(Color.Yellow, side);
      foreach (ColoredTriangle tri in cube)
      {
        CheckCoordinatesZeroOrSide(tri.Triangle.P1, side);
        CheckCoordinatesZeroOrSide(tri.Triangle.P2, side);
        CheckCoordinatesZeroOrSide(tri.Triangle.P3, side);
      }
    }

    private void CheckCoordinatesZeroOrSide(Vector3 vector3, float side)
    {
      Assert.IsTrue(vector3.X == 0 || vector3.X == side);
      Assert.IsTrue(vector3.Y == 0 || vector3.Y == side);
      Assert.IsTrue(vector3.Z == 0 || vector3.Z == side);
    }
  }
}
